#
# @lc app=leetcode.cn id=1010 lang=python3
#
# [1010] 总持续时间可被 60 整除的歌曲
#

# @lc code=start



from collections import defaultdict
from typing import List


class Solution:
    def numPairsDivisibleBy60(self, time: List[int]) -> int:
        ans = 0
        cnt = defaultdict(int)
        for i , x in enumerate(time):
            tag = (60 - (x % 60)) % 60
            if tag in cnt:
                ans += cnt[tag]
            cnt[x%60] += 1
        return ans
# @lc code=end

